package com.inepex.inechart.client.displayengine;

import java.util.ArrayList;

import com.google.gwt.user.client.ui.Widget;


public class Layer {

	protected LayerGroup parent;
	protected int zIndex;
	protected ArrayList<Widget> widgets;
	protected LayerPosition layerPosition;
	
	protected Layer(LayerGroup parent) {
		this.parent = parent;
		widgets = new ArrayList<Widget>();
		layerPosition = LayerPosition.relative;
	}

	public int getzIndex() {
		return zIndex;
	}
	
	public void setzIndex(int zIndex) {
		this.zIndex = zIndex;
	}
	
	public ArrayList<Widget> getWidgets() {
		return widgets;
	}

	public LayerPosition getLayerPosition() {
		return layerPosition;
	}

	public void setLayerPosition(LayerPosition layerPosition) {
		this.layerPosition = layerPosition;
	}

	public void bringToTop(){
		setLayerPosition(LayerPosition.always_on_top);
	}
	
	public void bringToBottom(){
		setLayerPosition(LayerPosition.always_on_bottom);
	}
		
	public void setOpacity(double opacity){
		for (Widget w : widgets) {
			w.getElement().getStyle().setOpacity(opacity);
		}
	}
	
	public void hide(){
		setOpacity(0.0);
	}
	
}
